package powell.nflpredictionproject.display;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import javax.swing.*;

/**
 *
 * @author Verti_000
 */

/*
 * This class extends the JFrame class and is used when the calculateOne button
 * is clicked. This class displays the prediction of one game.
 */
public class OneGameResultPanel extends JFrame
{
    /*
     * This is the component declarations on the class level.
     */

    private JPanel buttonPanel = new JPanel();
    private JButton resetButton = new JButton("Reset");
    private JButton exitButton = new JButton("Exit");
    private JLabel output = new JLabel("Default");
    public JPanel tempPanel = new JPanel(new BorderLayout());

    /*
     * This is the constructor for the OneGameResultPanel class.
     */
    public OneGameResultPanel()
    {

        resetButton.setToolTipText("ALT-R to Reset");
        resetButton.setMnemonic(KeyEvent.VK_R);

        exitButton.setToolTipText("ALT-E to Exit");
        exitButton.setMnemonic(KeyEvent.VK_E);


        this.setBounds(100, 100, 1150, 900);

        output.setForeground(Color.WHITE);

        buttonPanel.add(resetButton);
        buttonPanel.add(exitButton);

        resetButton.addActionListener(new ResetListener());

        exitButton.addActionListener(new ExitListener());

        buttonPanel.setBackground(Color.BLACK);

        this.getContentPane().setBackground(Color.BLACK);

        this.setTitle("One Game Prediction");

        output.setFont(new Font("Serif", Font.PLAIN, 28));

        output.setHorizontalAlignment(SwingConstants.CENTER);

        this.setLayout(new GridLayout(3, 1));

        this.add(output);

        this.add(tempPanel);

        this.add(buttonPanel);

        this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

        this.setResizable(false);

        this.setVisible(true);
    }

    /*
     * This method allows outside classes the ability to access the JLabel
     * output's .setText() method using a parameter passed to this method.
     * 
     * @param text
     */
    public void setOutputText(String text)
    {
        output.setText(text);
    }

    /*
     * This method calls the .setVisible() and .dispose() methods of this to
     * close the JFrame.
     */
    private void closeMe()
    {
        this.setVisible(false);
        this.dispose();
    }

    /*
     * This class implements an ActionListener and listens for when the exit
     * button is clicked and then exits the program.
     */
    private class ExitListener implements ActionListener
    {

        @Override
        public void actionPerformed(ActionEvent e)
        {
            System.exit(1);
        }
    }

    /*
     * This class implements an ActionListener and listens for when the reset
     * button is clicked and then calls a new MainPanel object and calls the
     * closeMe() method to close this JFrame.
     */
    private class ResetListener implements ActionListener
    {

        @Override
        public void actionPerformed(ActionEvent e)
        {
            MainPanel newWindow = new MainPanel();
            closeMe();
        }
    }
}
